import { post, get } from '@/http/index'
import type { ScheduleModel } from '@/type/Schedule'
import { DeconstructionKvModel } from '@/utils/objUtils'
export async function getSchedule(pk: string) {
  return await get<ScheduleModel>("Schedule/Get", { pk: pk })
}
export async function initFromTemplate(dseClass: string, start: string, end: string) {
  return await post<ScheduleModel>("Schedule/InitFromTemplate", { dseClass, start, end })
}
export async function listSchedule(cond: any) {
  return await post<ScheduleModel>("Schedule/List", cond)
}
export async function listScheduleByClass(cls: string) {
  return await get<ScheduleModel>("Schedule/ListByClass", { dseClass: cls })
}

export async function saveSchedule(data: ScheduleModel) {
  DeconstructionKvModel(data)
  return await post<ScheduleModel>("Schedule/Save", data)
}
export async function delSchedule(pk: string) {
  return await post<ScheduleModel>("Schedule/Delete", { pk: pk })
}
export async function listByTeacher(teacher: string, start: string, end: string) {
  return await get<ScheduleModel>("Schedule/ListByTeacher", { teacher, start, end })
}
export async function listByClass(dseClass: string, start: string, end: string) {
  return await get<ScheduleModel>("Schedule/ListByClass", { dseClass, start, end })
}
export async function removeByClass(dseClass: string, date: string) {
  return await post<string>("Schedule/RemoveByClass", { dseClass, start: date, end: date })
}
export async function exchange(one: string, other: string) {
  return await post<string>("Schedule/Exchange", { one, other })
}
export async function move(from: string, to: string) {
  return await post<string>("Schedule/Move", { from, to })
}